import Hips from '@hips/vue-core';
import { AppDsx } from '@hips/plugin-dataset-vuex';
import HipsI18n from '@hips/plugin-vue-i18n';
import FastClick from 'fastclick';
import App from './App.vue';

import 'x-photoswipe/dist/photoswipe.css';
import 'x-photoswipe/dist/default-skin/default-skin.css';
import './style/reset.css';
import './style/normalize.css';

import { Toast, Indicator, Dialog, Notify, Actionsheet } from '@hips/vue-ui';
import { createAxios } from './request';

import Feida from '@feida/core';
import Render from '@feida/plugin-vue-render';
import Jssdk from '@hipsfe/plugin-vue-cross-jssdk';

Feida.use(Render);
Feida.use(Jssdk);

const FeidaPlugin = new Feida();

const fetch = FeidaPlugin.createFetch(createAxios());

const plugins = [
  Toast,
  Indicator,
  Dialog,
  Notify,
  Actionsheet,
  {
    plugin: AppDsx,
    options: {
      axios: fetch,
    },
  },
  {
    plugin: HipsI18n,
    options: {
      defaultLocale: 'zh',
    },
  },
  {
    plugin: FeidaPlugin,
    options: {
      localStoragePre: process.env.VUE_APP_LOCALSTORAGE_PRE,
    },
  },
];

const hips = new Hips({
  el: '#app',
  root: App,
  useDsx: true,
});

hips.inject(plugins);

hips.start({});

new FastClick(document.body);
